#include<cstdio>
#include<cstring>
const int maxn=200001;
int f[maxn],c[maxn],a[maxn];
int m,n;
int low(int x)
{
	return x&(x^(x-1));
}
int find(int x)
{
	if(x!=f[x])
		f[x]=find(f[x]);
	return f[x];
}
void add(int x,int v)
{
	while(x<=n)
	{
		c[x]+=v;
		x+=low(x);
	}
}
int sum(int x)
{
	int ans=0;
	while(x>0)
	{
		ans+=c[x];
		x-=low(x);
	}
	return ans;
}
int 
int main()
{
	freopen("test.in","r",stdin);
	scanf("%d%d",&n,&m);
	int num=n;
	for(int i=1;i<=n;i++){f[i]=i;a[i]=1;}
	add(1,n);
	for(int i=1;i<=m;i++)
	{
		int op,x,y,k;
		scanf("%d",&op);
		if(op==0)
		{
			scanf("%d%d",&x,&y);
			x=find(x);
			y=find(y);
			if(x==y)continue;
			add(a[x],-1);
			add(a[y],-1);
			add(a[y]=a[x]+a[y],1);
			f[x]=y;
			num--;
		}
		else
		{
			scanf("%d",&k);
			k=num-k+1;
			printf("%d\n",find_kth(k));
		}
	}
	return 0;
}


		
